class Solution {
public:
    vector<int>path;
    int k;
    int n;
    vector<vector<int>> ret;
    vector<vector<int>> combine(int _n, int _k) {
        k=_k;
        n=_n;
        dfs(1);
        return ret;
    }

    void dfs(int pos)
    {
        if(path.size()==k)
        {
            ret.push_back(path);
            return;
        }

        for(int i=pos;i<=n;++i)
        {
            path.push_back(i);
            dfs(i+1);
            path.pop_back();
        }
    }
};
